﻿@{
    Layout = "~/Views/Shared/_Index.cshtml";
 }
<div class="container-div">
    <div class="row">
        <div id="searchDiv" class="col-sm-12 search-collapse">
            <input type="hidden" id="newsid" col="newsid">
            <div class="select-list">
                <ul>
                    <li>
                        用户名：<input id="username" col="username" type="text" />
                    </li>
                    <li>
                        <a id="btnSearch" class="btn btn-primary btn-sm" onclick="searchGrid()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                    </li>
                </ul>
            </div>
        </div>
        @* <div class="btn-group-sm hidden-xs" id="toolbar">
            <a id="btnAdd" class="btn btn-success" onclick="showSaveForm(true)"><i class="fa fa-plus"></i> 新增</a>
            <a id="btnEdit" class="btn btn-primary disabled" onclick="showSaveForm(false)"><i class="fa fa-edit"></i> 修改</a>
            <a id="btnDelete" class="btn btn-danger disabled" onclick="deleteForm()"><i class="fa fa-remove"></i> 删除</a>
        </div>*@
        <div class="btn-group-sm hidden-xs" id="toolbar">
            <a id="btnExport" class="btn btn-warning" onclick="exportForm()"><i class="fa fa-download"></i> 导出</a>
        </div>
        <div class="col-sm-12 select-table table-striped">
            <table id="gridTable" data-mobile-responsive="true"></table>
        </div>
    </div>
</div>

<script type="text/javascript">
    var id = ys.request("id");
    $(function () {
        $("#newsid").val(id);
        initGrid();
    });

    function initGrid() {
        var queryUrl = '@Url.Content("~/QixingManage/UserActivityRegistration/GetPageListJson")';
        $('#gridTable').ysTable({
            url: queryUrl,
            columns: [
                { checkbox: true, visible: true },
                { field: 'Id', title: 'Id', visible: false },
                { field: 'username', title: '用户名称' },
                { field: 'realname', title: '真实姓名' },
                { field: 'cardId', title: '身份证' },
                { field: 'telephone', title: '联系电话' },
                { field: 'sex', title: '性别' },
                { field: 'time', title: '报名时间', formatter: function (value, row, index) {
                        return ys.formatDate(value, "yyyy-MM-dd HH:mm:ss");
                    }
                },
            ],
            queryParams: function (params) {
                var pagination = $('#gridTable').ysTable('getPagination', params);
                var queryString = $('#searchDiv').getWebControls(pagination);
                return queryString;
            }
        });
    }

    function searchGrid() {
        $('#gridTable').ysTable('search');
        resetToolbarStatus();
    }

     function exportForm() {
        var url = '@Url.Content("~/QixingManage/UserActivityRegistration/ExportUserActivityRegistrationJson")';
         var postData = $("#searchDiv").getWebControls();
         var selectedRow = $("#gridTable").bootstrapTable("getSelections");
         if (selectedRow.length>0)
         {
             var ids = ys.getIds(selectedRow);
             postData.ids = ids;
         }
        ys.exportExcel(url, postData);
    }

    //function showSaveForm(bAdd) {
    //    var id = 0;
    //    if (!bAdd) {
    //        var selectedRow = $('#gridTable').bootstrapTable('getSelections');
    //        if (!ys.checkRowEdit(selectedRow)) {
    //            return;
    //        }
    //        else {
    //            id = selectedRow[0].Id;
    //        }
    //    }
    //    ys.openDialog({
    //        title: id > 0 ? '编辑' : '添加',
    //        content: '@Url.Content("~/QixingManage/UserActivityRegistration/UserActivityRegistrationForm")' + '?id=' + id,
    //        width: '768px',
    //        height: '550px',
    //        callback: function (index, layero) {
    //            var iframeWin = window[layero.find('iframe')[0]['name']];
    //            iframeWin.saveForm(index);
    //        }
    //    });
    //}

    //function deleteForm() {
    //    var selectedRow = $('#gridTable').bootstrapTable('getSelections');
    //    if (ys.checkRowDelete(selectedRow)) {
    //        ys.confirm('确认要删除选中的' + selectedRow.length + '条数据吗？', function () {
    //            var ids = ys.getIds(selectedRow);
    //            ys.ajax({
    //                url: '@Url.Content("~/QixingManage/UserActivityRegistration/DeleteFormJson")' + '?ids=' + ids,
    //                type: 'post',
    //                success: function (obj) {
    //                    if (obj.Tag == 1) {
    //                        ys.msgSuccess(obj.Message);
    //                        searchGrid();
    //                    }
    //                    else {
    //                        ys.msgError(obj.Message);
    //                    }
    //                }
    //            });
    //        });
    //    }
    //}
</script>
